package com.springboot.file.util.easyexcel.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

import java.math.BigDecimal;

/**
 * 自定义NUMBER类型转换器，使用CustomBigDecimalConverter进行实际处理
 * 保留此类以保持与旧代码的兼容性
 */
public class CustomNumberConverter implements Converter<BigDecimal> {

    // 使用CustomBigDecimalConverter进行实际处理
    private final CustomBigDecimalConverter delegate = new CustomBigDecimalConverter();

    @Override
    public Class<BigDecimal> supportJavaTypeKey() {
        return BigDecimal.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.NUMBER;
    }

    @Override
    public BigDecimal convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        // 委托给CustomBigDecimalConverter进行处理
        return delegate.convertToJavaData(cellData, contentProperty, globalConfiguration);
    }

    @Override
    public WriteCellData<?> convertToExcelData(BigDecimal value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        // 委托给CustomBigDecimalConverter进行处理
        return delegate.convertToExcelData(value, contentProperty, globalConfiguration);
    }
}
